#ifndef TEMPADC_H
#define TEMPADC_H

#include "../main.h"
#include "TempSysType.h"

//使用之前需要实现函数接口: adc_model_init();
//初始化调用: ADInit();
//ADC工作时钟源,2ms定时调用: ADClock();

// #define Debug_ADC 1

#ifdef Debug_ADC
extern uint32_t DebugAdc[11];
#endif

#define AD_GPIO_PIN_SEL  ((1ULL<<IO_Oven) | (1ULL<<IO_Probe1) | (1ULL<<IO_Probe2) | (1ULL << IO_Vref))

typedef enum
{
    RTD_Seq_Vref = 0, //参考电压采集序号
    RTD_Seq_RTD = 1, //RTD采集序号
    RTD_Seq_Probe1 = 2, //Probe1采集序号
    RTD_Seq_Probe2 = 3, //Probe2采集序号
    
    RTD_Seq_End,
}RTD_Seq_E;
typedef struct __RTD
{
    int32_t value; //Integer that contains the process value
    _Pt_Status status;
}_RTD;
extern _RTD RTD[4];

typedef struct
{
    int32_t oven;
    uint16_t oven_set;
    _Pt_Status oven_Err; //0,正常, 1:开路报错, 2:短路报错, 3:低温报警, 4:高温报警
    int32_t probe1;
    uint16_t probe1_Err;
    int32_t probe2;
    uint16_t probe2_Err;
    uint32_t timer;
    uint8_t p_value;
}_Temp_Param;
extern _Temp_Param Temp_Param;

typedef struct
{
    void (*LowTemp_Handle)(void);
}TempDetection_S;
extern TempDetection_S TempDetection;


extern uint8_t LowTemp_Ctrl;
extern esp_adc_cal_characteristics_t *adc_chars;
extern uint16_t temp_con_state;

void ADInit(void);
void ADC_Clock_2ms(void);
void ADC_KeyUpDown(void);
void ADC_Filter(void);
void ADSampling(void);

#endif
